/* Start Header
*****************************************************************/
/*!
\file   TSSocket.h
\author <Liu Wei Long, weilong.liu, 250002510>
        <Liu Zhi Yang, zhiyang.liu, 300000111>
\par    <email: weilong.liu\@digipen.edu> 
        <email: zhiyang.liu\@digipen.edu> 
\date   <Apr 3, 2012>
\brief
Copyright (C) 2012 DigiPen Institute of Technology.
Reproduction or disclosure of this file or its contents without the
prior written consent of DigiPen Institute of Technology is prohibited.
*/
/* End Header
*******************************************************************/
#ifndef _TSSOCKET_H_
#define _TSSOCKET_H_

#include "WinsockHeaders.h"

class TSSocket
{

public:
	TSSocket(void);
	TSSocket(SOCKET socket);
	~TSSocket();

	std::string GetIPAddress(void);
	SOCKET GetSocket(void) const { return mSocket; }

	// Wrapper function for send/recv data
	int SendUDPData(const char* data, int numOfBytes, const std::string& ip_address, int port_num);
	bool RecvUDPData(char* data, int& numOfBytesRead);

	// Client-side Functionalities
	int SetUpUDPClientAddress(const char* portnumber);

	// Server-side Functionalities
	bool SetUpUDPServerAddress(unsigned int &port_num);

	std::string mIPAddress;
	sockaddr_in fromaddr;
private:
	SOCKET mSocket;

	CRITICAL_SECTION mCSLockSend;
	CRITICAL_SECTION mCSLockRecv;
};

#endif

